<template>
  <el-container>
    <el-aside width="200px">
      <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <el-submenu
          v-for="item in allRouter"
          :key="item.meta.index"
          :index="item.meta.index"
        >
          <template slot="title">
            <i class="el-icon-location"></i>
            <span slot="title">{{ item.name }}</span>
          </template>
          <el-menu-item-group>
            <router-link
              v-for="val in item.children"
              :to="val.path"
              :key="val.path"
              ><el-menu-item :index="val.path"
                ><i class="el-icon-location"></i
                >{{ val.meta.title }}</el-menu-item
              ></router-link
            >
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>Header</el-header>
      <el-main>
        <router-view />
      </el-main>
      <el-footer>Footer</el-footer>
    </el-container>
  </el-container>
</template>

<script>
import loginVue from "./login.vue";
export default {
  name: "home",
  computed: {
    allRouter() {
      let r = this.$router.options.routes.filter((item, index) => {
        return index > 1;
      });
      return r;
    },
  },
  data() {
    return{
      route: "/test/test1",
    }
  },
  mounted() {
    // console.log(this.$router, 88888);
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style>
.el-menu {
  height: 100%;
  width: 200px;
  /* width: 100%; */
}
.el-container {
  height: 100%;
  width: 100%;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>